package com.sbj.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sbj.config.DynamicTaskConfig;
import com.sbj.dto.req.MemberStoreReq;
import com.sbj.dto.res.BuyGoodsRes;
import com.sbj.dto.res.CountDownRes;
import com.sbj.dto.res.MemberStoreRes;
import com.sbj.service.IBuyGoodsService;
import com.sbj.service.IMemberStoreService;
import com.zmh.framework.sys.dto.request.common.PageResponseDTO;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author summer
 * @version 1.0
 * @date 2024/8/12 08:57
 */
@RestController
@RequestMapping(value = "/member_buy_goods")
@AllArgsConstructor
public class MemberGoodsStoreController {

    private final IBuyGoodsService buyGoodsService;

    /**
     * 抢购商品列表
     * @param pageResponseDTO
     * @return
     */
    @PostMapping(value = "/lists")
    public Result<Page<BuyGoodsRes>>  lists(@RequestBody PageResponseDTO pageResponseDTO){
        return Result.successResult(buyGoodsService.webBuyGoods(pageResponseDTO));
    }

    private final DynamicTaskConfig dynamicTaskConfig;

    @GetMapping(value = "/count_down")
    public Result<CountDownRes> countDown(){
        dynamicTaskConfig.run();
        return Result.successResult(buyGoodsService.countDown());
    }


}
